/* Ultrasonic-Sensor

The following sketch was created by Richard Huebl in September of 2011.

*/

int uSsig = 22; // Ultrasound signal pin
  
int echoTime(){
   int uStime = 0;
   pinMode(uSsig, OUTPUT);
   
   digitalWrite(uSsig, LOW); // Send low pulse
   delayMicroseconds(2); // Wait for 2 microseconds
   digitalWrite(uSsig, HIGH); // Send high pulse
   delayMicroseconds(5); // Wait for 5 microseconds
   digitalWrite(uSsig, LOW); // Holdoff
   
   pinMode(uSsig, INPUT);
   return (pulseIn(uSsig, HIGH));       
}

void setup() {
  Serial.begin(9600);                  // Sets the baud rate to 9600
}

void loop() {
  Serial.println(echoTime());
  Serial.println();
  delay(1000);
}
